package com.liuwei.desktop.common;

import java.util.Vector;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class AWTUtils {
	
	public static void removeRows(JTable table){
		DefaultTableModel model = (DefaultTableModel) table.getModel();
	    for (int i = model.getRowCount() - 1; i >= 0; i--) {
	       model.removeRow(i);
	    }  
	}
	
	public static void refreshTable(JTable table,DefaultTableModel model){
		removeRows(table);
		if(model!=null){
			DefaultTableModel oldmodel = (DefaultTableModel) table.getModel();
		    for (int i = 0; i <model.getRowCount(); i++) {
			    oldmodel.addRow((Vector) model.getDataVector().get(i));
			}  
	        oldmodel.fireTableDataChanged();
		}
	}

}
